#define _CRT_SECURE_NO_WARNINGS


int majorityElement(int* nums, int numsSize) 
{
    int c, i, j;
    for (i = 0, j = 0, c = nums[i]; i < numsSize; i++) 
    {
        if (nums[i] == c)
        {
            j++;
        }
        else 
        {
            if (j > 0)
            {
                j--;
            }
            else c = nums[i];
        }
    }
    return c;
}
